<script src="__PUBLIC__/ganged/Js/city-picker.data.js"></script>
<script src="__PUBLIC__/ganged/Js/city-picker.js"></script>
<script src="__PUBLIC__/ganged/Js/main.js"></script>
<!-- css -->
<link href="__PUBLIC__/ganged/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/ganged/Css/city-picker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/upload.js" ></script>
<style>
.bg{ background: none; border: none;}
.uploadify-button-text{ display: inline-flex; }
.uploadify-button-text button{ margin: -10px; }
.upviewer img{ height:90px; width: 120px; }
.upviewer ul{ margin:0px; padding:0px; }
.upviewer li{ margin:0px; padding:0px; position: relative; display:inline-block; width:120px; height:90px; background-position: center; background-size: contain; background-repeat: no-repeat; float: left; margin-right:10px; border:1px #ccc solid; background-color:#f0f0f0;}
.upviewer li a{ display:inline-block; position: absolute; bottom:0px; left:0px; text-align:center; width:100%; background-color:rgba(0,0,0,0.3); color:red; cursor: pointer; }
.upviewer li:hover a{ background-color:rgba(0,0,0,0.8); }
</style>
<div class="container" style="padding-top: 50px;">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <form class="form-horizontal" role="form" id="post_form" action="{:U('edit')}">
                <div class="form-group">
                    <label for="title" class="col-sm-2 control-label">标题:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="title" id="title" value="{$info.title}"/>
                    </div>
                </div>

                <div class="form-group">
                     <label for="user_name" class="col-sm-2 control-label">姓名:</label>
                    <div class="col-sm-6">
                        <input type="text" class="form-control" name="user_name" id="user_name" value="{$info.user_name}"/>
                    </div>
                </div>

                <div class="form-group">
                    <label for="mobile" class="col-sm-2 control-label">手机:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="mobile" id="mobile" value="{$info.mobile}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="buy_year" class="col-sm-2 control-label">购买年份:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="buy_year" id="buy_year" value="{$info.buy_year}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="buy_month" class="col-sm-2 control-label">购买月份:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="buy_month" id="buy_month" value="{$info.buy_month}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="mahjong_parts" class="col-sm-2 control-label">配件:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="mahjong_parts" id="mahjong_parts" value="{$info.mahjong_parts}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="new_old_degree" class="col-sm-2 control-label">新旧程度:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="new_old_degree" id="new_old_degree" value="{$info.new_old_degree}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="mahjong_style" class="col-sm-2 control-label">款式:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="mahjong_style" id="mahjong_style" value="{$info.mahjong_style}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="mahjong_size" class="col-sm-2 control-label">麻将牌大小:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="mahjong_size" id="mahjong_size" value="{$info.mahjong_size}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="mahjong_num" class="col-sm-2 control-label">数量:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="mahjong_num" id="mahjong_num" value="{$info.mahjong_num}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">是否可售:</label>
                    <div class="col-sm-10">
                        <label for="is_sales1" class="control-label">
                            <input type="radio" id="is_sales1" name="is_sales" value="0" <if condition="$info['is_sales'] neq 1">checked</if>>否
                        </label>
                        <label for="is_sales2" class="control-label">
                            <input type="radio" id="is_sales2" name="is_sales" value="1"  <if condition="$info['is_sales'] eq 1">checked</if>>是
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="intentional_rent" class="col-sm-2 control-label">意向租金:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="intentional_rent" id="intentional_rent" value="{$info.intentional_rent}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="sale_price" class="col-sm-2 control-label">销售价格:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="sale_price" id="sale_price" value="{$info.sale_price}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="img" class="col-sm-2 control-label">图片:<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_img">
                        <input type="file" class="form-control" id="img" value="{$info.img}"><br /> 
                        <div name="img" class="upviewer">
                            <ul>
                                <notempty name="info['img']">
                                    <li>
                                        <input type="hidden" name="img[]" value="{$info.img}">
                                        <img src="{$info.img}"/><a d_path="{$info.img}">删除</a>
                                    </li>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="images" class="col-sm-2 control-label">轮播:<span style="color: red;">*</span></label>
                    <div class="col-sm-10 js_upload_imgs">
                        <input type="file" class="form-control" id="images"><br /> 
                        <div name="images" class="upviewer">
                            <ul>
                                <notempty name="info['images']">
                                    <php>
                                        $info['images'] = explode(',', $info['images']) ;
                                    </php>
                                    <volist name="info['images']" id="img">
                                        <li>
                                            <input type="hidden" name="images[]" value="{$img}">
                                            <img src="{$img}"/><a d_path="{$img}">删除</a>
                                        </li>
                                    </volist>
                                </notempty>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="address" class="col-sm-2 control-label">地址:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="address" id="address" value="{$info.address}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="lng" class="col-sm-2 control-label">经度:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="lng" id="lng" value="{$info.lng}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="lat" class="col-sm-2 control-label">纬度:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="lat" id="lat" value="{$info.lat}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="remarks" class="col-sm-2 control-label">备注:</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="remarks" id="remarks" value="{$info.remarks}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">状态:</label>
                    <div class="col-sm-10">
                        <label for="status1" class="control-label">
                            <input type="radio" id="status1" name="status" value="0" <if condition="$info['status'] neq 1">checked</if>>下架
                        </label>
                        <label for="status2" class="control-label">
                            <input type="radio" id="status2" name="status" value="1"  <if condition="$info['status'] eq 1">checked</if>>上架
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                         <input type="hidden" name="id" value="{$info.id}">
                        <button type="button" class="btn btn-primary" id="btn" lng="0" lat="0">提交</button>
                    </div>
                </div>
            </form>
        </div>
</div>
<script>
$(function(){   
     
    $("#btn").click(function(){
        // 省市区
        var $form = $("#post_form");
        var $data = {};
        var $form_data = $form.serializeArray();
        $.each($form_data, function(k, v){
            $data[v['name']] = v['value'];
        })
        
        $.post($form.attr('action'), $data, function(obj){
            alert(obj.m);
            if(obj.s){
                if(typeof(obj.url)!= "undefined" && obj.url){
                    location.href = obj.url;
                }
            }
        })
        return false;
    })
});
</script>
